﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

/// <summary>
/// Summary description for StockInformation
/// </summary>
public class StockInformation
{
  private const string SP = "StockInformation_GetById";
  DatabaseManager db;
  MySqlDataReader reader;

  public string Id { get; set; }
  public int Year { get; set; }
  public double SharePrice { get; set; }
  public double NumberOfShares { get; set; }
  public int CashFlowFromOperatingActivities { get; set; }
  public int Dividend { get; set; }

	public StockInformation()
	{
    db = new DatabaseManager();
	}

  public void Load(string id, int year)
  {
    db.AddParameter("@id", id);
    db.AddParameter("@year", year);
    using (reader = db.ExecuteStoredProcedure(SP))
    {
      while (reader.Read())
      {
        Id = reader["id"].ToString();
        Year = Convert.ToInt32(reader["year"].ToString());
        SharePrice = Convert.ToDouble(reader["share_price"].ToString());
        NumberOfShares = Convert.ToDouble(reader["number_of_shares"].ToString());
        CashFlowFromOperatingActivities = Convert.ToInt32(reader["cash_flow_from_operating_activities"].ToString());
        Dividend = Convert.ToInt32(reader["dividend"].ToString());
      }
    }
  }
}